package br.com.caelum.vraptor.dao;

import javax.persistence.NoResultException;


import br.com.caelum.vraptor.entidades.Professor;

public class ProfessorDAO extends GenericJPADAO<Professor> {
	
	public ProfessorDAO(){
		this.persistentClass = Professor.class;
	}
	public Professor find(String email, String senha){
		try{
			Professor n = getEm().createQuery("select a from Professor a where a.email like :email and a.senha = :senha", Professor.class)
		   .setParameter("email", email)
		   .setParameter("senha", senha)
		   .getSingleResult();
			return n;
		}
		catch(NoResultException e){
			return null;
		}
	}
}
